package com.example.demo.service.impl;

import com.example.demo.entity.second.Student;
import com.example.demo.repository.second.StudentRepository;
import com.example.demo.service.StudentService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {

    private final StudentRepository studentRepository;

    public StudentServiceImpl(StudentRepository studentRepository) {
        this.studentRepository = studentRepository;
    }

    @Transactional
    @Override
    public Student add(Student student) {
        return studentRepository.save(student);
    }

    @Override
    public List<Student> list() {
        return studentRepository.findAll();
    }
}
